//
//  ForgetPswVC.m
//  hnGovernment
//
//  Created by 安仔 on 17/3/3.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "ForgetPswVC.h"
#import "RegisterView.h"
#import "SetUpPswView.h"
#import "DDbaseNetWork+Login.h"

@interface ForgetPswVC ()<RegisterViewDelegate, SetUpPswViewDelegate>

@property (nonatomic, strong) RegisterView *topHalfView;
@property (nonatomic, strong) SetUpPswView *bottomHalfView;

@end

@implementation ForgetPswVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = NSLocalString(@"忘记密码");
    
    self.topHalfView = [[RegisterView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 514 * m6Scale)];
    self.topHalfView.nextBtn.hidden = YES;
    self.topHalfView.pactLab.hidden = YES;
    self.topHalfView.phoneTF.placeholder = NSLocalString(@"请输入注册手机号");
    self.topHalfView.checkTF.placeholder = NSLocalString(@"请输入验证码");
    self.topHalfView.delegate = self;
    self.topHalfView.isForgetPassword = YES;
    
    [self.view addSubview:self.topHalfView];
    
    
    self.bottomHalfView = [[SetUpPswView alloc] initWithFrame:CGRectMake(0, 514 * m6Scale, KScreenWidth, 440 * m6Scale)];
    
    [self.bottomHalfView.secondTF mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bottomHalfView.mas_centerX);
        make.top.mas_equalTo(self.bottomHalfView.firstTF.mas_bottom).offset(40 * m6Scale);
        make.size.mas_equalTo(CGSizeMake(600 * m6Scale, 80 * m6Scale));

    }];
    [self.bottomHalfView.sureBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bottomHalfView.mas_centerX);
        make.top.mas_equalTo(self.bottomHalfView.secondTF.mas_bottom).offset(80 * m6Scale);
        make.size.mas_equalTo(CGSizeMake(600 * m6Scale, 80 * m6Scale));
    }];
    
    self.bottomHalfView.delegate = self;
    
    [self.view addSubview:self.bottomHalfView];


}
- (void)clickSureBtn {
    [DDNetWorkManager forgetPwdRestPassword:self.bottomHalfView.firstTF.text confirmPassword:self.bottomHalfView.secondTF.text smsCode:self.topHalfView.checkTF.text mobile:self.topHalfView.phoneTF.text controller:self success:^(id result, DDcacheType cacheType, DDresultType resultType) {
        [DDHudHelper showHudWithResult:result resultSuccess:^{
            [SVProgressHUD showSuccessWithStatus:@"修改成功,请登录"];
            [self.navigationController popViewControllerAnimated:YES];
        }];
    } failure:^(NSError *error) {
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
